package org.wak.scene
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import org.wak.baseoneonline.flash.geom.IntPoint;

	/**
	 * Action spot, Class to define an intearactable area on the scene
	 * over the background. 
	 * 
	 */
	public class ActionSpot extends Sprite implements ISceneInteractable
	{
		protected var mId:String = "";
		protected var mName:String = "" ;
		protected var mDescription:String = "" ;
		protected var mInteractionPoint:IntPoint = null ;
		protected var mInteractionBehaviour:String = "" ;
		protected var mSceneId:String = "" ;
		protected var mDefaultAction:String = "" ;
		protected var mShapeArr:Array = null ;
		protected var mEnabled:Boolean = true ;
		
		public function ActionSpot(pDef:IActionSpotDefinition)
		{
			super();
			
			mId = pDef.id ;
			mName = pDef.name ;
			mDescription = pDef.description ;
			mInteractionPoint = pDef.interactionPoint ;
			mInteractionBehaviour = pDef.interactionBehaviour ;
			mDefaultAction = pDef.defaultAction ;
			mEnabled = pDef.enabled ;
			
			mShapeArr = pDef.shape ;
			var fFirstPoint:IntPoint = mShapeArr[0] ;
			
			
			var fAlpha:Number = 0 ;
			if( pDef.visible )
				fAlpha = 1;
			
			this.graphics.beginFill(0xFF0000,fAlpha);
			//this.graphics.drawRect(0,0,100,100 );
			
				for each( var point:IntPoint in mShapeArr )
				{
					this.graphics.lineTo( point.x, point.y);
					//this.graphics.moveTo( point.x, point.y);
					 
					
				}
				if(fFirstPoint != null)
				{
					this.graphics.lineTo( fFirstPoint.x, fFirstPoint.y);
				}
				
			this.graphics.endFill();
			
			this.x = pDef.position.x ;
			this.y = pDef.position.y ;
		}
		
		public function get interactableId():String
		{
			return mId;
		}
		
		public function get displayObject():DisplayObject
		{
			return this as DisplayObject;
		}
		
		public function get interactionPointX():Number
		{
			return mInteractionPoint.x;
		}
		
		public function get interactionPointY():Number
		{
			return mInteractionPoint.y;
		}
		
		public function get interactionName():String
		{
			return mName;
		}
		
		public function get baseline():int
		{
			return 0;
		}
		
		public function get interactionBehaviour():String
		{
			return mInteractionBehaviour;
		}
		
		public function get unitaryUse():Boolean
		{
			return false;
		}
		
		public function get sceneId():String
		{
			return mSceneId;
		}
		
		public function set sceneId(value:String):void
		{
			mSceneId = value ; 
		}
		
		public function get description():String
		{
			return mDescription;
		}
		
		public function get defaultAction():String
		{
			return mDefaultAction;
		}
		
		public function get enabled():Boolean
		{
			return mEnabled ;
		}
		
		public function set enabled(value:Boolean):void
		{
			mEnabled = value;
		}
		
	}
}